package cn.jsj.hzu.qm.facecloud.utils;

import java.io.IOException;
import java.io.InputStream;
import java.util.LinkedList;

public class FileProcesser {
	private LinkedList<Integer> bytes = new LinkedList<Integer>(); //原始数据
	
	private LinkedList<LinkedList<Integer>> splitBySymble = new LinkedList<LinkedList<Integer>>();
	
	public FileProcesser(InputStream inputStream) throws IOException {
		int b;
		int b2 = 0, b3 = 0, b4 = 0;
		LinkedList<Integer> itemIntegers = new LinkedList<Integer>();
		while((b = inputStream.read()) != -1) {
			itemIntegers.add(b);
			
			
			
//			System.out.printf("%X\n", b);
			if (b4 == 0x0d && b3 == 0x0a && b2 == b4 && b == b3) {
				System.out.println("换了");
				splitBySymble.add(itemIntegers);
				itemIntegers = new LinkedList<Integer>();
			}else if (b4 == 0x0d && b3 == 0x0a && b2 == 0x2d && b == 0x2d) {
				System.out.println("换了");
				splitBySymble.add(itemIntegers);
				itemIntegers = new LinkedList<Integer>();
			}
			
			b4 = b3;
			b3 = b2;
			b2 = b;//后移一位，等待新的
		}
		splitBySymble.add(itemIntegers);//最后一个
		
	}
	
	public LinkedList<LinkedList<Integer>> getSplitBySymble() {
		return splitBySymble;
	}
	
}
